/ Assembly List / LJCTextDataReaderLib / TextDataReader / LJCSetObjectValues

Namespace - LJCTextDataReaderLib


Parameters
dataObject - The data object.
dataFields - The DbColumns data field definitions object.

Syntax

C#
public Void LJCSetObjectValues(Object dataObject, DbColumns dataFields = null)

Sets the data object property values from the TextDataReader. (RE)

Remarks

The custom DbColumns data field definitions are used if provided. Otherwise the internal LJCDataFields property value is used.

This method uses the DbColumn.ColumnName (or DbColumn.RenameAs if provided) for the source column name and the DbColumn.PropertyName for the object property name.

Example

C#
using LJCTextDataReaderLib;

public class Person
{
  public string FirstName { get; set; }
  public string LastName { get; set; }
}

// The hasHeadingLine defaults to true if the parameter is not included.
TextDataReader textReader = new TextDataReader();

string[] lines = new string[]
{
  "FirstName, LastName",
  "John, Doe",
  "Jane, Doe"
};

// The field delimiter defaults to "," if the parameter is not included.
textReader.LJCSetLines(lines);

while(textReader.ReadLine())
{
  Person person = new Person();
  textReader.LJCSetObjectValues(person);
  // First record person.FirstName = "John", person.LastName = "Doe"
  // second record person.FirstName = "Jane", person.LastName = "Doe"
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.